package com.gmako.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.gmako.service.BaseService;
import com.gmako.utils.Constants;
import com.gmako.utils.Pager;

@Controller
@RequestMapping("/student.do")
public class MyTestController {
	@Autowired(required=false) 
	private BaseService baseService;
	
	@RequestMapping
	public String testCon(HttpServletRequest request){
		System.out.println("2222222222222");
//		List<Userinfo> li= baseService.findAll();
//		for (Userinfo userinfo : li) {
//			System.out.println(userinfo.getEmail());
//		}
		this.getPageNo(request);
		Pager p=baseService.findPagerAll(5, 0, "Userinfo");
		System.out.println(p.getResultList().size());
		request.setAttribute("pager", p);
		return "MyJsp";
	}
	public int getPageNo(HttpServletRequest request){
		int pageNo = 0;
		if (request.getParameter("pageNo") != null
				&& !"".equals(request.getParameter("pageNo"))) {
			pageNo = Integer.parseInt(request.getParameter("pageNo"));

		} else {
			pageNo = Constants.pageNo;
		}
		return pageNo;
	}
}
